package bao;

import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;

public class UserDeal {
    public Boolean login(String name,String pwd) {
        DataBasePool pool = DataBasePool.getPool();
        String sql = "SELECT * FROM login WHERE name='" + name + "';";
        System.out.println(sql);
        Connection con = null;
        try {
            con = pool.getConnection();
            Statement sta = con.createStatement();
            ResultSet set = sta.executeQuery(sql);
            if (set.next()) {
                String name1 = set.getString("name");
                String pwd1 = set.getString("pwd");
                if(pwd.equals(pwd1))
                    return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}
